const baseUrl = "http://kumanxuan1.f3322.net:8001";
export default function request(url,params={}){
	return new Promise((resolve,reject)=>{
		if (wx.getStorageSync('token')) {
			params.header = {
				"X-Nideshop-Token":wx.getStorageSync('token')
			}
		}
		wx.showLoading({
			title: '加载中',
		})
		wx.request({
			url: baseUrl+url,
			data:params.data || {},
			header:params.header || {},
			method:params.method || 'GET',
			timeout:5000,
			dataType:"json",
			success:res=>{
				resolve(res);
				wx.hideLoading();
			},
			fail:err=>{
				wx.hideLoading();
				console.log(err);
				reject(err)
			}
		})
	})
}